package com.wswy.wzcx.ui.other;

import android.graphics.Color;
import android.os.CountDownTimer;
import android.support.v4.content.ContextCompat;
import android.widget.TextView;

import com.wswy.wzcx.R;

/**
 * Created by wangduheng26 on 2018/1/19.
 * wangduheng26@gmail.com
 */

public class DownTimer extends CountDownTimer{
    TextView mTextView;

    public DownTimer(long second, long secondInterval, TextView view) {
        super(second*1000, secondInterval*1000);
        mTextView=view;
    }

    @Override
    public void onTick(long l) {
        mTextView.setEnabled(false);
        mTextView.setText((l/1000)+"秒后再发送");
        mTextView.setTextColor(Color.parseColor("#8c8d99"));
    }

    @Override
    public void onFinish() {
        cancel();
        mTextView.setEnabled(true);
        mTextView.setText("重新发送");
        mTextView.setTextColor(ContextCompat.getColor(mTextView.getContext(), R.color.colorAccent));

    }
}
